package cn.mes.module.mes.dal.mysql.basemachineinfo;

import java.util.*;

import cn.mes.framework.common.pojo.PageResult;
import cn.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.mes.framework.mybatis.core.mapper.BaseMapperX;
import cn.mes.module.mes.dal.dataobject.basemachineinfo.BaseMachineInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.mes.module.mes.controller.admin.basemachineinfo.vo.*;

/**
 * 机台产线基础信息 Mapper
 *
 * @author 游创
 */
@Mapper
public interface BaseMachineInfoMapper extends BaseMapperX<BaseMachineInfoDO> {

    default PageResult<BaseMachineInfoDO> selectPage(BaseMachineInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseMachineInfoDO>()
                .eqIfPresent(BaseMachineInfoDO::getWorkShopId, reqVO.getWorkShopId())
                .eqIfPresent(BaseMachineInfoDO::getMachineAreaId, reqVO.getMachineAreaId())
                .likeIfPresent(BaseMachineInfoDO::getMachineName, reqVO.getMachineName())
                .eqIfPresent(BaseMachineInfoDO::getMachineProperty, reqVO.getMachineProperty())
                .eqIfPresent(BaseMachineInfoDO::getMachineBrand, reqVO.getMachineBrand())
                .eqIfPresent(BaseMachineInfoDO::getHasWeight, reqVO.getHasWeight())
                .eqIfPresent(BaseMachineInfoDO::getIsScheduling, reqVO.getIsScheduling())
                .eqIfPresent(BaseMachineInfoDO::getIsMachine, reqVO.getIsMachine())
                .eqIfPresent(BaseMachineInfoDO::getMachineAreaId, reqVO.getMachineAreaId())
                .eqIfPresent(BaseMachineInfoDO::getMachinePlcId, reqVO.getMachinePlcId())
                .eqIfPresent(BaseMachineInfoDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(BaseMachineInfoDO::getRegionId, reqVO.getRegionId())
                .eqIfPresent(BaseMachineInfoDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BaseMachineInfoDO::getOffline, reqVO.getOffline())
                .orderByAsc(BaseMachineInfoDO::getMachineName)
                .orderByAsc(BaseMachineInfoDO::getOrderNo));
    }

    default int deleteByWorkShopId(String workShopId) {
        return delete(BaseMachineInfoDO::getWorkShopId, workShopId);
    }

}